/*
 * testing shuffle function
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
	printf("This is a noisy test");
	struct gameState G;
	int i,idx,game1;
	int indicator[2]={0,0};
	int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};

	game1 = initializeGame(2, k, 1, &G);

	for(i = 0; i < 2; i++) {
		printf("\nPlayer: %d current deck: ", i + 1);
		int old[(&G)->deckCount[i]];
		for(idx = 0; idx < (&G)->deckCount[i]; idx++){
			printf("%d,", (&G)->deck[i][idx]);
			old[idx]=(&G)->deck[i][idx];
		}
		printf("\n");
		game1 = shuffle(i, &G);

		if (game1 == 0) {
			printf("shuffle success at %d!\n",i);
		} else {
			printf("shuffle failed at %d!\n",i);
		}
		
		printf("\nPlayer: %d shuffled deck: ", i + 1);
		
		for(idx = 0; idx < (&G)->deckCount[i]; idx++)
			printf("%d,", (&G)->deck[i][idx]);

		printf("\ntesting if the deck is shuffled\n");

		for(idx = 0; idx < (&G)->deckCount[i]; idx++){
			if(old[idx]!=(&G)->deck[i][idx]){
				indicator[i]++;		
				printf("shuffled at pos: %d with ind val: %d\n",idx,indicator[i]);
			}			
		}

	}
		if(indicator[0]>0 && indicator[1]>0){
			printf("\nunit test3: all test passed!\n\n");	
		}
	return 0;
}
